package com.xht.security.oauth2.server.authorization.token;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenClaimsContext;
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenClaimsSet;
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer;

/**
 * <h1>描述 ：</h1>
 * Sets the {@link OAuth2TokenCustomizer} that customizes the
 * {@link OAuth2TokenClaimsContext#getClaims() claims} for the {@link OAuth2AccessToken}.
 *
 * @author : 小糊涂
 * @version : 1.0
 **/
@Slf4j
public class XhtOAuth2TokenCustomizer implements OAuth2TokenCustomizer<OAuth2TokenClaimsContext> {
    /**
     * 自定义OAuth 2.0 Token属性。
     *
     * @param context 包含OAuth 2.0 Token属性的上下文
     */
    @Override
    public void customize(OAuth2TokenClaimsContext context) {
        log.info("增加token属性: {}", context);
        OAuth2TokenClaimsSet.Builder claims = context.getClaims();
        claims.claim("code", 200);
    }
}
